{% load listurl %}

{% if page.paginator.num_pages != 1 %}
<div class="paginator">
{% if page.has_previous %}
 <span class="prev">
  <a href="{% listurl page=page.previous_page_number %}"
     title="Previous Page">&laquo;</a></span>
{% else %}
 <span class="prev-na">&laquo;</span>
{% endif %}

{% if page.paginator.trailing_set %}
 {% for p in page.paginator.trailing_set %}
 <span class="page"><a href="{% listurl page=p %}" >{{ p }}</a></span>
 {% endfor %}
        ...
{% endif %}

{% for p in page.paginator.adjacent_set %}
  {% if p == page.number %}
    <span class="curr" title="Current Page">{{ p }}</span>
  {% else %}
    <span class="page"><a href="{% listurl page=p %}"
     title="Page {{ p }}">{{ p }}</a></span>
  {% endif %}
{% endfor %}

{% if page.paginator.leading_set %}
        …
 {% for p in page.paginator.leading_set %}
    <span class="page"><a href="{% listurl page=p %}">{{ p }}</a></span>
 {% endfor %}
{% endif %}

{% if page.has_next %}
 <span class="next">
  <a href="{% listurl page=page.next_page_number %}"
   title="Next Page">&raquo;</a>
  </span>
{% else %}
 <span class="next-na">&raquo;</span>
{% endif %}
</div>
{% endif %}
